﻿using UnityEngine;
using System.Collections;

namespace edu.wpi.cs.Project1
{
    /// <summary>
    /// The blinking collider.
    /// </summary>
    public class BlinkCollider : MonoBehaviour
    {
        public const float BLINK_TIME = 1.0f;

        /// <summary>
        /// The blink timer.
        /// </summary>
        private float blinkTimer = 0.0f;

        /// <summary>
        /// Initialization.
        /// </summary>
        void Start()
        {

        }

        /// <summary>
        /// Update is called once per frame
        /// </summary>
        void Update()
        {
            blinkTimer += Time.deltaTime;

            if (blinkTimer > BLINK_TIME)
            {

                if (this.renderer.enabled)
                {
                    this.renderer.enabled = false;
                    this.collider.enabled = false;
                }
                else
                {
                    this.renderer.enabled = true;
                    this.collider.enabled = true;
                }

                blinkTimer = 0.0f;
            }

        }
    }
}

